import json


class Shape:
    def __init__(self, x):
        self.x = x

    def square(self):
        raise NotImplementedError


print('------------------------------三角形面积---------------------------------')


class Triangle(Shape):
    def __init__(self, x, y):
        super().__init__(x)
        self.y = y

    def square(self):
        print("三角形的面积")
        if isinstance(self.x, (int, float)) and isinstance(self.y, (int, float)):
            print(round(self.x*self.y/2, 2))
        else:
            print(self.x, type(self.x), self.y, type(self.y))
            print('输入正确的数据类型')


T1 = Triangle(3, 4.1)

T1.square()

print('------------------------------矩形面积---------------------------------')


class Rectangle(Shape):
    def __init__(self, x, z):
        super().__init__(x)
        self.z = z

    def square(self):
        print("矩形的面积")
        if isinstance(self.x, (int, float)) and isinstance(self.z, (int, float)):
            print(self.x * self.z)
        else:
            print(self.x, type(self.x), self.z, type(self.z))
            print('输入正确的数据类型')


R1 = Rectangle(3.2, 4)
R1.square()


print('------------------------------圆形面积---------------------------------')


class Circulr(Shape):
    "圆形的面积计算，输入圆的半径即可"
    def __init__(self, x):
        super().__init__(x)
        self.__i = 3.14

    def square(self):
        print("圆形的面积")
        if isinstance(self.x, (int, float)):
            print(self.x ** 2 * self.__i)
        else:
            print(self.x, type(self.x), self.x, type(self.x))
            print('输入正确的数据类型')


class DumpMixin:
    def dumpsmsg(self):
        print("实例信息")
        print(self.__dict__, type(self.__dict__))
        print('序列化信息')
        print(json.dumps(self.__dict__), type(json.dumps(self.__dict__)))


class Dumpscc(DumpMixin, Circulr):
    pass


print('__doc__:', Circulr.__doc__)
C1 = Dumpscc(3)
C1.square()
C1.dumpsmsg()
print(Dumpscc.__mro__)



# 做的不错

